﻿using Aweber.Entity;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using Aweber;
using System.Configuration;

namespace UnitTests
{
    
    
    /// <summary>
    ///This is a test class for AccountTest and is intended
    ///to contain all AccountTest Unit Tests
    ///</summary>
    [TestClass()]
    public class AccountTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for Account Constructor
        ///</summary>
        [TestMethod()]
        public void AccountConstructorTest()
        {
            MockAdapter adapter = new MockAdapter();

            Account target = new Account(adapter);
            
            Assert.IsNotNull(target);
            Assert.IsNotNull(target.api);
        }

        /// <summary>
        ///A test for lists
        ///</summary>
        [TestMethod()]
        public void listsTest()
        {
           
            string appId = ConfigurationManager.AppSettings["AweberAppId"];
            API api = new API(appId, new MockAdapter());
            api.process_appId_token(ConfigurationManager.AppSettings["AweberToken"]);
            
            Account target = api.getAccount();

            BaseCollection<List> actual;
            actual = target.lists();
            Assert.IsTrue(actual.entries.Count > 0);

        }

        /// <summary>
        ///A test for integrations_collection_link
        ///</summary>
        [TestMethod()]
        public void integrations_collection_linkTest()
        {
            string appId = ConfigurationManager.AppSettings["AweberAppId"];
            API api = new API(appId, new MockAdapter());
            api.process_appId_token(ConfigurationManager.AppSettings["AweberToken"]);

            Account target = api.getAccount();
                        
            string actual;
            actual = target.integrations_collection_link;

            Assert.IsFalse(String.IsNullOrEmpty(actual));
        }

        /// <summary>
        ///A test for lists_collection_link
        ///</summary>
        [TestMethod()]
        public void lists_collection_linkTest()
        {
            string appId = ConfigurationManager.AppSettings["AweberAppId"];
            API api = new API(appId, new MockAdapter());
            api.process_appId_token(ConfigurationManager.AppSettings["AweberToken"]);

            Account target = api.getAccount();
            string actual;
            actual = target.lists_collection_link;
            Assert.IsFalse(String.IsNullOrEmpty(actual));
        }
    }
}
